CHANNEL_ANALYSIS_CONFIG = {
    'real_time_report': False,
    'dynamic_argument': True,
    'target_event_id': ['active', 'register', 'bind', 'recharge'],
    'interval_type_list': ['day', 'week', 'month'],
    'group_by': '_chn.keyword',
    'values': [
        {
            "value_id": "register_user",
            "target_value": "_user_id",
            "value_name": "注册账号",
            "filter": [
                {'term': {'_event_id': 'register'}}
            ],
            "operation": "value_count",
            "description": "当日新创建用户数量"
        },
        {
            "value_id": "register_user_rate",
            "value_name": "注册账号占比",
            "value_expr": "register_user / ${total_register_user}",
            "is_percentage": True,
            "fmt": lambda v: float("%.2f" % (v * 100)),
            "description": "当日渠道注册账号 / 所有注册账号"
        },
        {
            "value_id": "real_register_user",
            "target_value": "_user_id",
            "value_name": "绑定账号",
            "filter": [
                {"term": {"_event_id": "bind"}}
            ],
            "operation": "cardinality",
            "description": "当日进行手机号绑定的用户数量"
        },
        {
            "value_id": "real_register_rate",
            "value_name": "注绑率",
            "value_expr": "real_register_user / register_user",
            "is_percentage": True,
            "fmt": lambda v: float("%.2f" % (v * 100)),
            "description": "当日新绑定账号 / 新用户登录账号"
        },
        {
            "value_id": "new_recharge_user",
            "target_value": "_user_id",
            "value_name": "新付费账号",
            "filter": [
                {"term": {"_event_id": "recharge"}},
                {"term": {"_is_new_user": 1}}
            ],
            "time_range": {
                "_registered_at": [0, 0]
            },
            "operation": "cardinality",
            "description": "当日付费的新用户数量"
        },
        {
            "value_id": "new_recharge_rate",
            "value_name": "新付费率",
            "value_expr": "new_recharge_user / register_user",
            "is_percentage": True,
            "fmt": lambda v: float("%.2f" % (v * 100)),
            "description": "当日新充值账号 / 新用户登录账号"
        },
        {
            "value_id": "new_recharge_price",
            "target_value": "recharge_price",
            "value_name": "新付费金额",
            "filter": [
                {"term": {"_event_id": "recharge"}},
                {"term": {"_is_new_user": 1}}
            ],
            "time_range": {
                "_registered_at": [0, 0]
            },
            "value_type": "float",
            "adjust_amount": True,
            "description": "当日新用户付费金额总和"
        },
        {
            "value_id": "new_arpu",
            "value_name": "新ARPU",
            "value_expr": "new_recharge_price / register_user",
            "adjust_amount": True,
            "description": "新用户活跃账号人均付费金额，新付费金额 / 新活跃账号"
        },
        {
            "value_id": "new_arppu",
            "value_name": "新ARPPU",
            "value_expr": "new_recharge_price / new_recharge_user",
            "adjust_amount": True,
            "description": "新用户付费账号人均付费金额，新付费金额 / 新付费账号"
        }
    ]
}
